using System;
using System.Drawing;

namespace GDI
{
    public static class PointExtentions
    {
        public static Point CreatePoint_Deg(double R, double AngleDeg)
        {
            return CreatePoint(R, AngleDeg * Math.PI / 180);
        }

        public static Point CreatePoint(double R, double Angle)
        {
            double
                        sin = Math.Sin(Angle),
                        cos = Math.Cos(Angle);
            return new Point((int)(R * cos), (int)(R * sin));
        }

        public static Point CreatePoint_Deg(int X, int Y, double AngleDeg)
        {
            return CreatePoint(X, Y, AngleDeg * Math.PI / 180);
        }

        public static Point CreatePoint(int X, int Y, double Angle)
        {
            double
                        sin = Math.Sin(Angle),
                        cos = Math.Cos(Angle);
            return new Point((int)(X * cos - Y * sin), (int)(X * sin + Y * cos));
        }

        public static Point Rotate_Deg(this Point Point, double AngleDeg)
        {
            return Rotate(Point, AngleDeg * Math.PI / 180);
        }

        public static Point Rotate(this Point Point, double Angle)
        {
            return CreatePoint(Point.X, Point.Y, Angle);
        }

        public static Point Add(this Point p1, Point p2)
        {
            return new Point(p1.X + p2.X, p1.Y + p2.Y);
        }

        public static PointF Add(this Point p1, PointF p2)
        {
            return new PointF(p1.X + p2.X, p1.Y + p2.Y);
        }

        public static Point Add(this Point p1, Size Size)
        {
            return new Point(p1.X + Size.Width, p1.Y + Size.Height);
        }

        public static Point Add(this Point p1, int X, int Y)
        {
            return new Point(p1.X + X, p1.Y + Y);
        }

        public static PointF Add(this Point p1, float X, float Y)
        {
            return new PointF(p1.X + X, p1.Y + Y);
        }

        public static Point Substract(this Point p1, Point p2)
        {
            return new Point(p1.X - p2.X, p1.Y - p2.Y);
        }

        public static PointF Substract(this Point p1, PointF p2)
        {
            return new PointF(p1.X - p2.X, p1.Y - p2.Y);
        }

        public static Point Substract(this Point p1, Size Size)
        {
            return new Point(p1.X - Size.Width, p1.Y - Size.Height);
        }

        public static Point Substract(this Point p1, int X, int Y)
        {
            return new Point(p1.X - X, p1.Y - Y);
        }

        public static Size GetSize(this Point p1, Point p2)
        {
            return new Size(Math.Abs(p2.X - p1.X), Math.Abs(p2.Y - p1.Y));
        }

        public static Rectangle GetRectangle(this Point p1, Point p2)
        {
            var lv_LeftUp = new Point(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y));
            var lv_Size = p1.GetSize(p2);
            return new Rectangle(lv_LeftUp, lv_Size);
        }
    }
}